# -*- encoding: utf-8 -*-
"""
File Name: launch.py
Description:
Author : 'lirui'
date: 2/6/2024
Contact: marjey_lee@163.com
Change Activity:
2/6/2024:
"""
from modules.blk.cmdb.cmdb_service import CMDBService
from projects.generation.create_zabbix_branch_dedicated_line_monitor.config.config import ZABBIX_SERVER_USERNAME, ZABBIX_SERVER_PASSWORD
from projects.generation.create_zabbix_branch_dedicated_line_monitor.services.create_zabbix_dedicated_line_monitor_items import \
    CreateZabbixBranchDedicatedLineMonitorItems


def _load_zabbix_server_login_info():
    """

    Returns:

    """
    data = CMDBService().select('zabbix_docker_info')
    return data['data']['info']


def _create_monitor_items():
    data = _load_zabbix_server_login_info()
    for d in data:
        if d['zabbix_container_type'] == 'branch_dedicated_line':
            creator = CreateZabbixBranchDedicatedLineMonitorItems(
                ip=d['docker_server_ip'],
                port=d['docker_server_port'],
                username=ZABBIX_SERVER_USERNAME,
                password=ZABBIX_SERVER_PASSWORD
            )
            creator()


def _main():
    _create_monitor_items()


if __name__ == '__main__':
    _main()
